pro plot_marc_mix,tit,file
;filename=file+'marc.sal'
filename='EXPVmaxagn1_'+file
 readmarc,filename,xf,y1,e1
;filename=file+'marc1.sal'
filename='EXPVmaxagnT_'+file
 readmarc,filename,xf1,y11,e11
;filename=file+'marcX.sal'
filename='EXPVmaxagn2_'+file
 readmarc,filename,xfX,y1X,e1X

 usersym,[-.5,.5],[0,0]
  PLOT, xf,y1,/xlog, PSYM=4,xtitle='Mpc',ytitle='MARC '+tit,yrange=[0.0,2.5],/nodata 
  oploterr,xf, y1,e1,6
  oplot,xf,y1+e1,psym=8
  oplot,xf,y1-e1,psym=8
  oplot,[0.01,100],[1,1],linestyle=1
  ;,type=3,xtitle='Mpc',ytitle='MARC '+tit,yrange=[0.8,1.2];,1.5;y1 *(1. + ee1) 
;  oplot,xf1,y11,psym=5
  oploterr,xf1, y11,e11,4
  oplot,xf1,y11+e11,psym=8
  oplot,xf1,y11-e11,psym=8
  oplot,[0.01,100],[1,1],linestyle=1
  ;,1.5;y1 *(1. + ee1) 
;  oplot,xfX,y1X,psym=6
  oploterr,xfX, y1X,e1X,5
  oplot,xfX,y1X+e1X,psym=8
  oplot,xfX,y1X-e1X,psym=8
  oplot,[0.01,100],[1,1],linestyle=1

  ;,1.5*;y1 *(1. + ee1) 

end
pro plt
;ps,"plot_marc_mix,'BA AGN 1','DR7agn1_'",'agn_un.ps',x=14,y=9
;ps,"plot_marc_mix,'BA AGN 1','EXPagn1_'",'Eagn_un.ps',x=14,y=9
ps,"plot_marc_mix,'BA AGN 1','marc.sal'",'Eagn_un.ps',x=14,y=9
spawn,'convert -density 200 Eagn_un.ps Eagn_un.png'
;ps,"plot_marc_mix,'BA AGN 2','DR7agn2_'",'agn_do.ps',x=14,y=9
;ps,"plot_marc_mix,'BA AGN 2','EXPagn2_'",'Eagn_do.ps',x=14,y=9
ps,"plot_marc_mix,'BA AGN 2','marcX.sal'",'Eagn_do.ps',x=14,y=9
spawn,'convert -density 200 Eagn_do.ps Eagn_do.png'
;ps,"plot_marc_mix,'BA AGN T','DR7agnT_'",'agn_TT.ps',x=14,y=9
;ps,"plot_marc_mix,'BA AGN T','EXPagnT_'",'agn_TT.ps',x=14,y=9
ps,"plot_marc_mix,'BA AGN T','marc.sal'",'agn_TT.ps',x=14,y=9
spawn,'convert -density 200 Eagn_TT.ps Eagn_TT.png'
end
pro plot_marc,tit,filename=filename

; readmarc,'ba_cross_edge',xf,y1,e1
; readmarc,'ba_dr6',xf,y1,e1
if (is_def(filename)) then begin
 readmarc,filename,xf,y1,e1
endif
;filename="agn_az_mr0.sal"
; readmarc,filename,xf,y1,e1
;filename="agn1_az_mr0.sal"
; readmarc,filename1,xf1,y1,e1
;filename="agn2_az_mr0.sal"
; readmarc,filename2,xf2,y2,e2

  j=where(e1 ne 0)
  ee1=e1
;;  ee1(j)=1/sqrt(e1(j))

  PLOT, xf,y1,/xlog, PSYM=4,xtitle='Mpc',ytitle='MARC '+tit,yrange=[0.8,1.2] 
 ;; ERRPLOT,xf, y1 *(1.- ee1), y1 *(1. + ee1) 
  plterr,xf, y1,ee1,1,1.5;y1 *(1. + ee1) 

; readmarc,'ba_cross_face',xf,y1,e1
; readmarc,filename,xf,y1,e1
;  j=where(e1 ne 0)
;  ee1=e1
;  ee1(j)=1/sqrt(e1(j))
; oPLOT, xf,y1, PSYM=5 
 ; plterr,xf, y1,ee1,1,1.5;y1 *(1. + ee1) 
end

pro readmarc,filename,xf,y1,e1
  nrows=file_lines(filename)
  openr,lun,filename,/get_lun
  xf=fltarr(nrows) 
  y1=fltarr(nrows) 
  e1=fltarr(nrows) 
  for i=0L,nrows-1 do begin
 	 readf,lun,xt,dump,y1t
	 xf[i]=xt
	 y1[i]=y1t
	 e1[i]=dump
  endfor
  close,lun & free_lun,lun
end


pro plterr,x_tab,u_tab,u_stab,col,gg
ntab=size(x_tab)
Ntab=ntab(1)
dxe=float(gg)/float(ntab)/2
FOR i=0,ntab-1 DO BEGIN
      oplot,[x_tab(i),x_tab(i)],u_tab(i)+u_stab(i)*[-0.5,0.5],color=mycolor(col)
      oplot,x_tab(i)+dxe*[-1,1],u_tab(i)+u_stab(i)*[0.5,0.5],color=mycolor(col)
      oplot,x_tab(i)+dxe*[-1,1],u_tab(i)-u_stab(i)*[0.5,0.5],color=mycolor(col)
END
end
